# 用requests框架 主要学习 代理
import requests

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
}

# 1. 非代理
url = "https://2025.ip138.com/"
resp = requests.get(url, headers=headers)
resp.encoding = 'utf-8'
print(resp.text)
resp.close()

# 2. 代理
url = "https://2025.ip138.com/"
proxies = {
    "http": "118.178.197.213:3128", # 请求是 http 走这个
    "https": "60.169.244.77:40016", # 请求是 https 走这个
}
resp = requests.get(url, headers=headers, proxies=proxies)
resp.encoding = 'utf-8'
print(resp.text)
resp.close()
